import pandas as pd

df = pd.read_csv(r"D:\py\pythonProject\population-data\data\temp\年度数据.csv",encoding="gbk")
df =df.iloc[:-1]
print(df.iloc[0:1,2:])
print(df.iloc[3:4,2:])
print(df.iloc[3:4,2:]/(df.iloc[0:1,2:]))
print(df["2023年"][0])
years = [str(year) for year in range(2023, 1948, -1)]
for i in range(len(years)):
    df[years[i]+"年"][3]=df[years[i]+"年"][3]/df[years[i]+"年"][0]
    print(df[years[i]+"年"][3])
df.iloc[3:4, 2:] = df.iloc[3:4, 2:].applymap(lambda x: round(x * 100, 2))
print(df.iloc[3:4, 2:])
df = df.iloc[3:]
df.to_csv(r"D:\py\pythonProject\population-data\data\temp\总城镇率数据.csv",encoding="gbk",index=False)